
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;




public class NCellRenderer implements TableCellRenderer{
    @Override
  public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
 
    JButton showButton = new JButton("View Articles");
    showButton.addActionListener(new ActionListener() {
            @Override
      public void actionPerformed(ActionEvent arg0) {
        JOptionPane.showMessageDialog(null, "HA-HA!");
      }
    });
 
    JPanel panel = new JPanel();
    panel.add(showButton);
 
    if (isSelected) {
      panel.setBackground(table.getSelectionBackground());
    }else{
      panel.setBackground(table.getSelectionForeground());
    }
    return panel;
  }
}